package com.bee.剑指offer;

import java.util.HashMap;
import java.util.Map;

public class 数组中只出现一次的两个数字 {

    public int[] FindNumsAppearOnce(int[] array) {
        int[] result = new int[2];
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < array.length; i++) {
            if (map.containsKey(array[i])) {
                map.put(array[i], map.get(array[i]) + 1);
            } else {
                map.put(array[i], 1);
            }
        }
        int index = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (index >= 2) {
                break;
            }
            if (entry.getValue() == 1) {
                result[index] = entry.getKey();
                index++;
            }
        }
        return result;
    }

    public static void main(String[] args) {


    }
}
